layui.use(['form','layer','element','laydate','laytpl'], function () {
     var laydate = layui.laydate,laytpl = layui.laytpl ,form = layui.form;

     $.get ('/userinfo/getGoogle' , null, function (data) {
         if(data.rel){
           $("#googleImg").attr("src",data.result.googleImg);
         }
     });

    form.on('submit(save)', function(data){
        submitForm(data);
       return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
     });

});

function submitForm(data){
  $.ajax({
     url: '/userinfo/setGoogle',
     type: 'post',
     data: data.field,
     dataType: "json",
     success: function (data) {
         var layerTips = parent.layer === undefined ? layui.layer : parent.layer;
         if(data.rel){
            layerTips.msg('保存成功');
           // parent.changeName($("#name").val());
             //parent.refreshMenu();
            //parent.location.reload();
         }else{
           layerTips.msg(data.msg);
         }
     }
   });
}

function setLabelValues(data) {
    for (var p in data) {
        $("#" + p + "").html(data[p]);
    }
}

function setInputValues(data) {
    for (var p in data) {
        $("#" + p + "").val(data[p]);
    }
}